<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;
use DB;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class CollectController extends Controller
{
	/**
     * 收藏夹页面
     *         
     * @return
     */
	//收藏夹列列表
	public function getIndex(Request $request)
	{	
		//获取id
		$uid = $request->input('uid');
		
		//匹配数据
		$res = DB::table('collect')
			->join('userdetails','collect.uid','=','userdetails.uid')
			->select('collect.*','userdetails.*')
			->where('collect.uid',$uid)
			->get();
		
		//问题表
		$wt = DB::table('issue')->where('uid',$uid)->get();
		//分配数据
		return view('home.scxx',['res'=>$res,'wt'=>$wt]);
	}

	//答案表
	public function getCat(Request $request)
	{	
		//获取id
		$id = $request->input('id');
 		//获取uid
		$uid = $request->input('uid');
		//获取用户信息
		$data = DB::table('userdetails')->where('uid',$uid)->get();

		//匹配数据
		$res = DB::table('answer')
			->join('issue','answer.Iid','=','issue.id')
			->select('answer.*','issue.atitle')
			->where('answer.Iid',$id)
			->get();
		//分配数据
		return view('home.lbxq',['res'=>$res,'data'=>$data]);
	}
	
}